package pers.vic.upload.socket.model;

/**
 * 描述: 文件上传进度信息
 * @author Vic.xu
 * @date 2022-07-15 11:24
 */
public class ProgressInfo {

    /**上传进度 0 -100*/
    private int progress;

    /**上传速度*/
    private String speed;

    /**
     * 计算上传进度
     * @param total
     * @param writePosition
     * @param speedText
     * @return
     */
    public static ProgressInfo create(long total, long writePosition, String speedText) {
        ProgressInfo progressInfo = new ProgressInfo();
        progressInfo.setSpeed(speedText);
        progressInfo.setProgress((int) Math.floorDiv(writePosition * 100, total));
        return progressInfo;

    }

    public int getProgress() {
        return progress;
    }

    public void setProgress(int progress) {
        this.progress = progress;
    }

    public String getSpeed() {
        return speed;
    }

    public void setSpeed(String speed) {
        this.speed = speed;
    }
}
